#ifndef FAVSDIALOG_H
#define FAVSDIALOG_H

/**
Nectarine Utility Project is a software interface for the web system 'demovibes'
Copyright (C) 2010  Alexandre LAURENT

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

website: http://code.google.com/p/nectarine-utility-project/
e-mail: lw.demoscene@gmail.com
**/

#include <QDialog>
#include <QList>

#include "Types/favorites.h"

class QWidget;
class QVBoxLayout;
class QHBoxLayout;
class QLabel;
class QFrame;
class QTableWidget;
class QPushButton;
class QSpinBox;

class QSignalMapper;

class FavsDialog : public QDialog
{
    Q_OBJECT

private:

    QVBoxLayout* pMainGrid;

    QLabel* pTitleLabel;
    QFrame* pHLine1;

    QFrame* pHLine2;
    QHBoxLayout* pButtonGrid;
    QPushButton* pPreviousPageButton;
    QPushButton* pNextPageButton;
    QLabel* pPageLabel;
    QSpinBox* pPageInput;
    QLabel* pPageMaximumLabel;
    QPushButton* pGoPageButton;

    QTableWidget* pFavsTable;

    QPushButton* pValidateButton;

    QSignalMapper* pRequestMapper;
    QSignalMapper* pUnFavMapper;
    QSignalMapper* pFavMapper;

    QString owner;
    bool isOwner;
    unsigned int nbPages;
    unsigned int currentPage;

protected slots:

    void accept(void);
    void reject(void);

    void checkRequest(int row);
    void checkFav(int row);
    void checkUnFav(int row);

    void previousPage(void);
    void nextPage(void);
    void goPage(void);

signals:

    void needLoadPage(FavsDialog* pFD, unsigned int pageNumber);

    void needRequestSong(int songID);
    void needFav(int songID);
    void needUnfav(int songID);

    void deleteFDSignal(FavsDialog*);

public:

    FavsDialog(const Favorites& favorites, const bool isOWner=false, const QList<int>& ownerFavList = QList<int>(), const bool isConnected=false, QWidget* parent=0);
    ~FavsDialog(void);

    void loadFavs(const Favorites& favorites, const QList<int>& ownerFavList = QList<int>());

    const QString& getOwner(void)const { return owner; }
    const bool getIsOwner(void)const { return isOwner; }
};

#endif // FAVSDIALOG_H
